<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" href="images/favicon.ico" type="image/x-icon">
    <link href="css/main.css" rel="stylesheet" type="text/css" />
    <title>下载牛数APP2.0</title>
</head>
<body>
    <div class="bg">
        <div class="container">
            <div class="system display" id="wechat">
                <div class="head">
                    <div>
                        <p class="tip_1">点击右上角选择浏览器打开</p>
                        <p class="tip_2">进入浏览器后点击下载</p>
                    </div>
                    <img src="images/svg/arrow.svg" alt="">
                </div>
            </div>
            <h3 id="weclome">欢迎下载牛数APP2.0</h3>
            <p class="info">全新功能等你来体验</p>
            <p class="qrcode"></p>
            <p>扫码下载APP</p>
            <div class="system">
                <div class="iphone" id="iphone">
                    <img src="images/svg/icon-iOS.svg" alt="iPhone" id="img_iphone">
                    <span id="name_iphone">iPhone</span>
                </div>
            </div>
            <div class="system">
                <div class="android" id="android">
                    <img src="images/svg/icon-Android.svg" alt="Android" id="img_android">
                    <span id="name_android">Android</span>
                </div>
            </div>
            <div class="footer">
                <a class="submit-btn" id="submit-btn">
                    点击下载
                </a>
            </div>
        </div>
    </div>

    <script type="text/javascript" src="js/rem.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript">
        var userAgentInfo = navigator.userAgent.toLowerCase();
        var flag=userAgentInfo.indexOf("android") > -1?false:true
        //flag===false 表示android true表示ios
        if (flag==false) {
            document.getElementById("android").style.border="2px solid #05D569"
            document.getElementById("name_android").style.color="#05D569"
            document.getElementById("img_android").src="images/svg/icon-Android-sure.svg"
        }else {
            document.getElementById("iphone").style.border="2px solid #05D569";
            document.getElementById("name_iphone").style.color="#05D569"
            document.getElementById("img_iphone").src="images/svg/icon-iOS-sure.svg"
        }
        if(/micromessenger/i.test(userAgentInfo)==true&&flag===false){
            //判断在安卓微信中打开，显示在浏览器中打开提示
            document.getElementById("wechat").style.display="flex";
        }else{
            document.getElementById("weclome").style.marginTop=".2rem";
        }
        if(document.body.clientWidth > document.body.clientHeight){
            //横屏显示方法
            document.getElementById("android").style.marginBottom = "1rem"//220px
        }
        //使用ajax连接下载接口appurls
        var appurl=""
        window.onload=function(){
            //调用安卓下载地址
            htmlobj=$.ajax({
                    url:"test/downloadNs",
                    async:false,
                    type:"post",
                });
            appurl = htmlobj.responseJSON.data.url
        }
        //点击下载方法
        $("#submit-btn").click(function(){
            if(/micromessenger/i.test(userAgentInfo)&&flag===false){
                alert("请点击右上角选择浏览器打开")
            }else if(flag===false){//在android打开直接下载
                // document.getElementById("submit-btn").href="https://www.bullbigdata.cn/bull-download/attachment/upload/appVersionInfo/201910/1016/19913aaa4f0b40619769ea290c81ceef.apk"
                document.getElementById("submit-btn").href=appurl
                console.log(appurl)
            }else if(flag===true){//在ios中打开进入应用商店
                document.getElementById("submit-btn").href="https://itunes.apple.com/app/id1449090814"
            }
        })

    </script>
</body>
</html>